home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.mactech.com 2010
/
ftp.mactech.com.tar
/
ftp.mactech.com
/
machack
/
Hacks97
/
WarriorsProgress.sit
/
Warrior’s Progress
/
source code
/
Source
/
Libraries
/
Heap
/
HeapLink.h
< prev
next >
Wrap
Text File
|
1997-06-28
|
1KB
|
51 lines
// HeapLink.h
#ifndef HeapLink_h
#define HeapLink_h
#ifndef Integers_h
#include "Integers.h"
#endif
#ifndef Assert_h
#include "Assert.h"
#endif
template < class Element > class Heap;
template < class Element >
class HeapLink
{
typedef Element ElementType;
typedef HeapLink< Element > LinkType;
typedef Heap< Element > HeapType;
typedef bool (ElementType::*Comparator)( const Element& ) const;
friend class Heap< Element >;
private:
Element *body;
HeapType *heap;
uint32 path;
LinkType *children[2];
void SwapWith( LinkType& );
bool operator<=( const LinkType& ) const;
bool operator>( const LinkType& r ) const { return !( *this <= r ); }
public:
HeapLink( Element *e = 0 );
~HeapLink();
bool Listed() const { return heap != 0; }
HeapType& Heap() const { Assert( heap != 0 ); return *heap; }
bool Null() const { return body == 0; }
Element *Target() const { return body; }
void PointTo( Element *b ) { body = b; }
Element& operator*() const { Assert( body != 0 ); return *body; }
Element *operator->() const { Assert( body != 0 ); return body; }
};
#endif